package com.experiment07;

import java.util.concurrent.CountDownLatch;

public class Test {
    public static void main(String[] args){
        SellStation s1 = new SellStation("1号售票点");
        SellStation s2 = new SellStation("2号售票点");
        SellStation s3 = new SellStation("3号售票点");


        new Thread(() -> {
            int count = 0;
            while(s1.sellTickets() != null){
                count++;

            }

            System.out.println("1号售票点售出" + count + "张票");
        }).start();

        new Thread(() -> {
            int count1 = 0;
            while(s2.sellTickets() != null){
                count1++;

            }
            System.out.println("2号售票点售出" + count1 + "张票");
        }).start();

        new Thread(() -> {
            int count2 = 0;
            while(s3.sellTickets() != null){
                count2++;

            }

            System.out.println("3号售票点售出" + count2 + "张票");
        }).start();
        try{ Thread.sleep(3000);
        }catch (InterruptedException e){
            System.out.println(e.getMessage());
        }

        if(s1.getTickets().size() + s2.getTickets().size() + s3.getTickets().size() == 200) {
            System.out.println("票数一致");
        }
    }


}
